﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xushre.WeiBoSDK {

    public partial class OClient2 {

        /// <summary>
        /// 获取某人的话题列表
        /// </summary>
        /// <param name="uid">需要获取话题的用户的UID。</param>
        /// <param name="count">单页返回的记录条数，默认为10。</param>
        /// <param name="page">返回结果的页码，默认为1。</param>
        /// <returns>JSON 格式的客串</returns>
        /// <exception cref="WeiboException"></exception>
        public string Trends(Int64 uid, int count = 10, int page = 1) {
            string response = string.Empty;
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("uid", uid);
            data.Add("count", count);
            data.Add("page", page);

            try {
                response = Get(API.OClient2.Trends.TRENDS, data);
            } catch (WeiboException e) {
                throw e;
            }

            return response;
        }

        /// <summary>
        /// 判断当前用户是否关注某话题
        /// </summary>
        /// <param name="trend_name">话题关键字。</param>
        /// <returns>JSON 格式的客串</returns>
        /// <exception cref="WeiboException"></exception>
        public string TrendsIsFollow(string trend_name) {
            string response = string.Empty;
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("trend_name", trend_name);

            try {
                response = Get(API.OClient2.Trends.TRENDS_IS_FOLLOW, data);
            } catch (WeiboException e) {
                throw e;
            }

            return response;
        }

        /// <summary>
        /// 返回最近一小时内的热门话题
        /// </summary>
        /// <param name="base_app">是否只获取当前应用的数据。0为否（所有数据），1为是（仅当前应用），默认为0。</param>
        /// <returns>JSON 格式的客串</returns>
        /// <exception cref="WeiboException"></exception>
        public string TrendsHourly(int base_app = 0) {
            string response = string.Empty;
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("base_app", base_app);

            try {
                response = Get(API.OClient2.Trends.TRENDS_HOURLY, data);
            } catch (WeiboException e) {
                throw e;
            }

            return response;
        }

        /// <summary>
        /// 返回最近一天内的热门话题
        /// </summary>
        /// <param name="base_app">是否只获取当前应用的数据。0为否（所有数据），1为是（仅当前应用），默认为0。</param>
        /// <returns>JSON 格式的客串</returns>
        /// <exception cref="WeiboException"></exception>
        public string TrendsDaily(int base_app = 0) {
            string response = string.Empty;
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("base_app", base_app);

            try {
                response = Get(API.OClient2.Trends.TRENDS_DAILY, data);
            } catch (WeiboException e) {
                throw e;
            }

            return response;
        }

        /// <summary>
        /// 返回最近一周内的热门话题
        /// </summary>
        /// <param name="base_app">是否只获取当前应用的数据。0为否（所有数据），1为是（仅当前应用），默认为0。</param>
        /// <returns>JSON 格式的客串</returns>
        /// <exception cref="WeiboException"></exception>
        public string TrendsWeekly(int base_app = 0) {
            string response = string.Empty;
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("base_app", base_app);

            try {
                response = Get(API.OClient2.Trends.TRENDS_WEEKLY, data);
            } catch (WeiboException e) {
                throw e;
            }

            return response;
        }

        /// <summary>
        /// 关注某话题
        /// </summary>
        /// <param name="trend_name">要关注的话题关键词。</param>
        /// <returns></returns>
        public string TrendsFollow(string trend_name) {
            string response = string.Empty;
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("trend_name", trend_name);

            try {
                response = Post(API.OClient2.Trends.TRENDS_FOLLOW, data);
            } catch (WeiboException e) {
                throw e;
            }

            return response;
        }

        /// <summary>
        /// 取消对某话题的关注
        /// </summary>
        /// <param name="trend_id">要取消关注的话题ID。</param>
        /// <returns>JSON 格式的客串</returns>
        /// <exception cref="WeiboException"></exception>
        public string TrendsDestory(Int64 trend_id) {
            string response = string.Empty;
            Dictionary<string, object> data = new Dictionary<string, object>();

            data.Add("trend_id", trend_id);

            try {
                response = Post(API.OClient2.Trends.TRENDS_DESTORY, data);
            } catch (WeiboException e) {
                throw e;
            }

            return response;
        }
    }
}
